Subscriptions

The subscription to Argo CD application events can be defined using notifications.argoproj.io/subscribe.<trigger>.<service>: <recipient> annotation. For example, the following annotation subscribes two Slack channels to notifications about every successful synchronization of the Argo CD application:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. metadata:
  4. annotations:
  5. notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my-channel1;my-channel2

The annotation key consists of following parts:

  • on-sync-succeeded - trigger name
  • slack - notification service name
  • my-channel1;my-channel2 - a semicolon separated list of recipients

You can create subscriptions for all applications of an Argo CD project by adding the same annotation to the AppProject resource:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: AppProject
  3. metadata:
  4. annotations:
  5. notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my-channel1;my-channel2

Default Subscriptions

The subscriptions might be configured globally in the argocd-notifications-cm ConfigMap using the subscriptions field. The default subscriptions are applied to all applications. The trigger and applications might be configured using the triggers and selector fields:

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: argocd-notifications-cm
  5. data:
  6. # Contains centrally managed global application subscriptions
  7. subscriptions: |
  8. # subscription for on-sync-status-unknown trigger notifications
  9. - recipients:
  10. - slack:test2
  11. - email:test@gmail.com
  12. triggers:
  13. - on-sync-status-unknown
  14. # subscription restricted to applications with matching labels only
  15. - recipients:
  16. - slack:test3
  17. selector: test=true
  18. triggers:
  19. - on-sync-status-unknown

If you want to use webhook in subscriptions, you need to store the custom webhook name in the subscription’s recipients field.

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: argocd-notifications-cm
  5. data:
  6. service.webhook.<webhook-name>: |
  7. (snip)
  8. subscriptions: |
  9. - recipients:
  10. - <webhook-name>
  11. triggers:
  12. - on-sync-status-unknown